package JavaSE.Class8;

public class Student {
    private String name;
    private int age;
    private int grade;
    private static String Num="113";

    public Student() {
        System.out.println("无参的构造方法被执行了");
    }

    public void show(){
        System.out.println("Name: " + name+" Age: " + age+" Grade: " + grade);
    }

    static {//在类加载的时候被执行 静态的只会执行一次
        Num="114";
        System.out.println("静态代码块在类加载的时候就被执行了");
    }

    {//构造代码块只有在使用了构造方法时才被执行
        this.name="zhang san";
        this.age=20;
        this.grade=30;
        System.out.println("构造代码块只有在使用了构造方法时才被执行");
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getGrade() {
        return grade;
    }

    public void setGrade(int grade) {
        this.grade = grade;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static String getNum() {
        return Num;
    }

    public static void setNum(String num) {
        Num = num;
    }

    public Student( String name, int age, int grade) {
        this.age = age;
        this.grade = grade;
        this.name = name;
        System.out.println("有参的构造方法被执行了");
    }
}
